import React, { Component } from 'react'
import PropTypes from 'prop-types'
import HighComponent from './Hoc'
import getDefaultOption from '../GenOptions'
class Rainfall extends Component {
  componentDidMount() {
    this.update()
  }
  componentDidUpdate() {
    // this.update()
  }
  update = () => {
    const { echart } = this.props
    const { result: { dates, averageRainfall } } = this.props
    echart.setOption(
      getDefaultOption('月平均降水(mm)',{}, dates, {
        name: '降雨量',
        type: 'line',
        symbolSize: 8,
        itemStyle: {
          normal: {
            lineStyle: {
              width: 1
            }
          }
        },
        data: averageRainfall
      }, function(value) {
        return value
      })
    )
  }
  render() {
    return (
      null
    )
  }
}
Rainfall.propTypes = {
  echart: PropTypes.object,
  result: PropTypes.object,
  unit: PropTypes.bool,
}
export default HighComponent(Rainfall, 'rainfall')